package com.api.shuigui.web;

import com.alibaba.fastjson.JSONObject;
import com.api.shuigui.service.DocContentService;
import com.api.shuigui.service.GrayModeService;
import com.api.shuigui.service.impl.DocContentServiceImpl;
import com.api.shuigui.service.impl.GrayModeServiceImpl;
import weaver.general.BaseBean;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
@WebServlet("/gray/getFlag")
public class GetGrayMode extends HttpServlet {
    BaseBean bb = new BaseBean();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/json;charset=utf-8");
        //初始化结果
        Map<String, Object> result = new HashMap<>();
        try{
            GrayModeService service = new GrayModeServiceImpl();
            result.putAll(service.getData());
            result.put("status",200);
        }catch (Exception e){
            e.printStackTrace();
            result.put("status", -1);
            result.put("msg", "获取数据异常！");
        }
        PrintWriter out = response.getWriter();
        //返回数据
        out.println(JSONObject.toJSONString(result));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
        super.doPost(req,res);
    }
}